package com.zzvcom.office.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 调试信息帮助类
 */
@Component
@Slf4j
public class LogSdkItemUtil {
    @Autowired
    private ObjectMapper objectMapper;

    public void log(Object obj) {
        if (obj != null) {
            if(log.isInfoEnabled()) {
                try {
                    log.info("obj={}", objectMapper.writeValueAsString(obj));
                } catch (JsonProcessingException e) {
                    log.error("log error", e);
                }
            }
        }else {
            log.info("obj is null");
        }
    }

}
